﻿namespace ShellNavigator.Client.Utils
{
  #region

  using System.Collections.Generic;
  using System.Collections.ObjectModel;

  #endregion

  /// <summary>
  ///     TODO: Update summary.
  /// </summary>
  public static class CollectionExtensions
  {
    #region Public Methods

    /// <summary>
    ///     Assigns the specified collection.
    /// </summary>
    /// <typeparam name = "T"></typeparam>
    /// <param name = "collection">The collection.</param>
    /// <param name = "source">The source.</param>
    public static void Assign<T>(this ObservableCollection<T> collection, IEnumerable<T> source)
    {
      collection.Clear();

      if (source != null)
      {
        foreach (var item in source)
        {
          collection.Add(item);
        }
      }
    }

    #endregion
  }
}